﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Colorful.Models
{
    public class Pager
    {
        private int _pageCount;
        private int _count;
        private int _pageSize;
        private int _page;

        public Pager(int page, int count, int pageSize, object datas)
        {
            _page = page;
            _pageSize = pageSize;
            this.count = count;
            this.datas = datas;
        }

        /// <summary>
        /// 分页数
        /// </summary>
        public int pageCount
        {
            get
            {
                if (_count > 0 && _pageCount == 0)
                {
                    _pageCount = _pageCount % _pageSize == 0 ? _pageCount / _pageSize : _pageCount / _pageSize + 1;
                }
                return _pageCount;
            }
        }
        /// <summary>
        /// 总记录数
        /// </summary>
        public int count
        {
            get
            {
                return _count;
            }
            set
            {
                _count = value;
                _pageCount = _count % _pageSize == 0 ? _count / _pageSize : _count / _pageSize + 1;
            }
        }
        /// <summary>
        /// 是否还有更多数据
        /// </summary>
        public bool haveMore
        {
            get
            {
                return _pageCount > _page + 1;
            }
        }
        /// <summary>
        /// Id
        /// </summary>
        public object datas { get; set; }
    }
}